﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Lv1;
using DG.Tweening;
public class JumpNumber : MonoBehaviour {

    private bool isJumping;

    private int curValue = 0;

    private Text text;

    public bool IsJumping {
        get {
            return isJumping;
        }
    }

	// Use this for initialization
	void Start () {
        text = GetComponent<Text>();
    }

    IEnumerator Jumping() {
        isJumping = true;
        yield return text.transform.DOScale(new Vector3(2, 2, 2), 0.3f).WaitForCompletion();
        yield return text.transform.DOScale(new Vector3(1, 1, 1), 0.2f).WaitForCompletion();
        isJumping = false;
    }
	
	// Update is called once per frame
	void Update () {
        if (text.text != "" && text.text != curValue.ToString()) {
            curValue = int.Parse(text.text);
            text.transform.localScale = Vector3.one;
            StartCoroutine(Jumping());
        }
	}
}
